home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 002 / chedit.arc / CGRAPH.C < prev    next >
C/C++ Source or Header  |  1986-07-23  |  2KB  |  73 lines

  1. /*
  2.    This program is placed in the public domain by its author, William Couture.
  3.    Copyright (c) 1986 by DDI.  All Rights Reserved.
  4. */
  5.  
  6. int readcset(shapes,fname)
  7.    unsigned char *shapes;
  8.    char *fname;
  9.    {
  10.    int charfile;
  11.                /* NOTE:  a file stream is not used, as it is possible that
  12.                   the byte being read from the file is a 26, which is an
  13.                   EOF mark (ctrl-Z).  Make sure that this routine is
  14.                   compatible with your compiler. */
  15.    int i,ch;
  16.  
  17.    charfile = open(fname,0);   /* open as read-only */
  18.    if (charfile == -1)
  19.       return(-1);          /* if it cannot be opened, return error */
  20.    read(charfile,shapes,1024);  /* read it */
  21.    close(charfile);
  22.    return(0);
  23.    }
  24.  
  25. int writecset(shapes,fname)
  26.    unsigned char *shapes;
  27.    char *fname;
  28.    {
  29.    FILE *charfile;
  30.    int i,ch;
  31.  
  32.    charfile = fopen(fname,"w");
  33.    if (charfile == NULL)
  34.       return(-1);          /* if it cannot be opened, return error */
  35.    for (i = 0; (i < 1024) && ((ch = fputc(shapes[i],charfile)) != EOF); i++)
  36.       ;
  37.    fclose(charfile);
  38.    if (ch == EOF)          /* if EOF encountered, return error */
  39.       return(-1);
  40.    else
  41.       return(0);
  42.    }
  43.  
  44. void printbanner(row,col,msg,length,color)
  45.    int row,col;
  46.    int *msg;
  47.    int length,color;
  48.            /* display a row of graphics characters */
  49.            /* Adding 128 (0x80) to the color will XOR draw the characters on
  50.              top of the existing screen */
  51.    {
  52.    int i;
  53.  
  54.    i = 0;
  55.    while (i < length)
  56.       gratchar(row,col++,msg[i++],color);
  57.    }
  58.  
  59. void printcolumn(row,col,msg,length,color)
  60.    int row,col;
  61.    int *msg;
  62.    int length,color;
  63.            /* display a column of graphics characters */
  64.            /* Adding 128 (0x80) to the color will XOR draw the characters on
  65.              top of the existing screen */
  66.    {
  67.    int i;
  68.  
  69.    i = 0;
  70.    while (i < length)
  71.       gratchar(row++,col,msg[i++],color);
  72.    }
  73.